#include "Plane4NodeIncomShpFunc.h"

using SG::DataStructure::Common::Real;
using SG::Algebra::Matrixd;
using SG::FEMSolver::Element::Plane4NodeIncomShpFunc;

Plane4NodeIncomShpFunc::Plane4NodeIncomShpFunc ()
:DNDxiSet ()
{}

/** @brief 计算积分点处非协调形函数的导数
 * 
 * 缓存各个积分点处的计算结果，避免下一次积分点循环时重复计算（内存换取计算时间）
 */

void Plane4NodeIncomShpFunc::Compute (const SG::DataStructure::FEM::IntegPointArray& integPoints)
{
    const auto nGauss = integPoints.size ();

    DNDxiSet.resize (nGauss);
    for (std::size_t index = 0; index < nGauss; ++index)
    {
        DNDxiSet[index] = Matrixd (2, 2);
        DNDxiSet[index] (0, 0) = -2.0 * integPoints[index].m_x;
        DNDxiSet[index] (1, 0) = 0.0;

        DNDxiSet[index] (0, 1) = 0.0;
        DNDxiSet[index] (1, 1) = -2.0 * integPoints[index].m_y;
    }
}